package com.pickgliss.ui.controls.tab
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.Dictionary;
	public class SimpleTabPanel extends TabPanel
	{
		
		public function SimpleTabPanel()
		{
			super();
		}
		
		private var _currentTab:DisplayObject;
		
		public function addTabAndContent(tab:DisplayObject):void
		{
			tab.addEventListener(MouseEvent.CLICK, __tabClickHandler);
			addTab(tab);
		}
		
		override public function dispose():void
		{
			for (var i:int = 0 ;i<_tabList.length;i++)
			{
				_tabList[i].removeEventListener(MouseEvent.CLICK, __tabClickHandler);
			}
			_currentTab = null;
			super.dispose();
		}
		
		private function __tabClickHandler(e:MouseEvent):void
		{
			var display:DisplayObject = e.currentTarget as DisplayObject;
			if(display == _currentTab) return;
			_currentTab = display;
			dispatchEvent(new Event(Event.CHANGE));
		}
	}
}